﻿using System.Web.Mvc;

namespace JinRi.Services.Helpers
{
    public static class HtmlHelperExtension
    {
        public static string CurrentAction(this HtmlHelper html)
        {
            return html.ViewContext.RouteData.Values["action"].ToString();
        }

        public static string CurrentController(this HtmlHelper html)
        {
            return html.ViewContext.RouteData.Values["controller"].ToString();
        }

        public static string CurrentActionClass(this HtmlHelper html, string action, string controller, string className)
        {
            return (html.CurrentAction().Equals(action, System.StringComparison.OrdinalIgnoreCase) && html.CurrentController().Equals(controller, System.StringComparison.OrdinalIgnoreCase))
                ? className : string.Empty;
        }

        public static string CurrentControllerClass(this HtmlHelper html, string controller, string className)
        {
            return html.CurrentController().Equals(controller, System.StringComparison.OrdinalIgnoreCase) ? className : string.Empty;
        }

        public static string GetCurrentUser(this HtmlHelper html)
        {
            return html.ViewContext.HttpContext.User.Identity.Name;
        }
    }
}